Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immutable CRAIEntry #1256

Merged
merged 7 commits into from
Jan 10, 2019
Merged

Immutable CRAIEntry #1256

merged 7 commits into from
Jan 10, 2019

Conversation

jmthibault79
Copy link
Contributor

@jmthibault79 jmthibault79 commented Jan 9, 2019

Description

Code cleanup for CRAIEntry

Checklist

  • Code compiles correctly
  • New tests covering changes and new functionality
  • All tests passing
  • Extended the README / documentation, if necessary
  • Is not backward compatible (breaks binary or source compatibility)

- explicitly set nOfRecords and index to 0
- remove unused sliceIndex
}
return entries;
return Arrays.stream(container.slices)
.map(slice -> slice.getCRAIEntry(slice.containerOffset))
Copy link
Contributor Author

@jmthibault79 jmthibault79 Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't necessarily derive the container offset from the Slice because sometimes it conflicts with the Container's own offset - will need to look into why.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have high confidence that these are managed correctly by the existing code, but in this case it's using the value from the slice anyway. Can we add a method to slice that uses it's offset directly, and if there is some other context for which that fails, maybe also add a static with this signature for that one case until we figure out whats going on, since thats the broken one ?

BTW, is slice.containerOffset supposed to be the offset of the containing container, or is it the offset of the slice relative to the beginning of the containing container ? Might be good to document those.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, any reason not to move this method to container getCRAIEntries just as it is, and have it return the list of entries. Eventually it should end up there I think, and would be similar to the new one you added to Slice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, these suggestions make sense.

Slice.containerOffset is the byte offset of the Container from the beginning of the stream.

Slice.offset is the byte offset of the Slice from the beginning of its Container.

I'll add comments making this more clear to Slice

@@ -114,19 +111,6 @@ public int compareTo(final CRAIEntry o) {
return (int) (containerStartOffset - o.containerStartOffset);
}

@Override
public CRAIEntry clone() throws CloneNotSupportedException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only tests were using this

e.sliceIndex = i;

entries.add(e);
final Map<Integer, AlignmentSpan> spans = s.getMultiRefAlignmentSpans(container.header, ValidationStringency.DEFAULT_STRINGENCY);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equivalent to what getCRAIEntriesForMultiRefSlice() did

entry.sliceOffset = 3;
entry.sliceSize = 4;
entry.containerStartOffset = 5;
final CRAIEntry entry = CRAIEntryTest.newEntry(0, 1, 2, 5, 3, 4);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preserves the values set above rather than the order

Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions/suggestions for the initial pass.

}
return entries;
return Arrays.stream(container.slices)
.map(slice -> slice.getCRAIEntry(slice.containerOffset))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have high confidence that these are managed correctly by the existing code, but in this case it's using the value from the slice anyway. Can we add a method to slice that uses it's offset directly, and if there is some other context for which that fails, maybe also add a static with this signature for that one case until we figure out whats going on, since thats the broken one ?

BTW, is slice.containerOffset supposed to be the offset of the containing container, or is it the offset of the slice relative to the beginning of the containing container ? Might be good to document those.

}
return entries;
return Arrays.stream(container.slices)
.map(slice -> slice.getCRAIEntry(slice.containerOffset))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, any reason not to move this method to container getCRAIEntries just as it is, and have it return the list of entries. Eventually it should end up there I think, and would be similar to the new one you added to Slice.

@codecov-io
Copy link

codecov-io commented Jan 9, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@5a0ab68). Click here to learn what that means.
The diff coverage is 85.714%.

@@            Coverage Diff             @@
##             master     #1256   +/-   ##
==========================================
  Coverage          ?   69.359%           
  Complexity        ?      8164           
==========================================
  Files             ?       548           
  Lines             ?     32682           
  Branches          ?      5521           
==========================================
  Hits              ?     22668           
  Misses            ?      7795           
  Partials          ?      2219
Impacted Files Coverage Δ Complexity Δ
...java/htsjdk/samtools/cram/structure/Container.java 84.211% <100%> (ø) 8 <1> (?)
...ain/java/htsjdk/samtools/cram/structure/Slice.java 45.536% <100%> (ø) 22 <2> (?)
src/main/java/htsjdk/samtools/cram/CRAIIndex.java 84.615% <81.818%> (ø) 27 <4> (?)
src/main/java/htsjdk/samtools/cram/CRAIEntry.java 71.053% <86.364%> (ø) 17 <8> (?)

Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lbergelson LGTM as an incremental step.

@lbergelson
Copy link
Member

@cmnbroad @jmthibault79 👍 Thank you.

@jmthibault79 jmthibault79 merged commit 94f0967 into master Jan 10, 2019
@jmthibault79 jmthibault79 deleted the jt_CRAIEntry branch January 10, 2019 21:26
tomwhite added a commit to tomwhite/disq that referenced this pull request Jan 16, 2019
…ry that

affects CramSource in Disq. See the note about incompatible CRAM changes
at https://github.com/samtools/htsjdk/releases/tag/2.17.0.

This commit uses the new CRAIEntry API introduced in samtools/htsjdk#1256
tomwhite added a commit to tomwhite/disq that referenced this pull request Jan 23, 2019
…ry that

affects CramSource in Disq. See the note about incompatible CRAM changes
at https://github.com/samtools/htsjdk/releases/tag/2.17.0.

This commit uses the new CRAIEntry API introduced in samtools/htsjdk#1256
tomwhite added a commit to tomwhite/disq that referenced this pull request Mar 12, 2019
…ry that

affects CramSource in Disq. See the note about incompatible CRAM changes
at https://github.com/samtools/htsjdk/releases/tag/2.17.0.

This commit uses the new CRAIEntry API introduced in samtools/htsjdk#1256
tomwhite added a commit to tomwhite/disq that referenced this pull request Mar 13, 2019
…ry that

affects CramSource in Disq. See the note about incompatible CRAM changes
at https://github.com/samtools/htsjdk/releases/tag/2.17.0.

This commit uses the new CRAIEntry API introduced in samtools/htsjdk#1256

remove use of SAMRecord.getIndexBin() since the method has been removed

Convert catch for EOFException -> RuntimeEOFException

Use htsjdk 2.19.0-rc3-SNAPSHOT

Use htsjdk 2.19.0
tomwhite added a commit to disq-bio/disq that referenced this pull request Mar 14, 2019
* The changes to CRAM have introduced an incompatible change to CRAIEntry that
affects CramSource in Disq. See the note about incompatible CRAM changes
at https://github.com/samtools/htsjdk/releases/tag/2.17.0.

This commit uses the new CRAIEntry API introduced in samtools/htsjdk#1256

* Convert catch for EOFException -> RuntimeEOFException

* Use htsjdk 2.19.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants